.animation-container {
  padding: 20px;
  /* 计算高度：100vh - 头部导航(64px) - 面包屑(48px) - Content的padding(48px) - 额外边距(40px) */
  height: calc(100vh - 200px);
  min-height: 500px; /* 设置最小高度防止过小 */
  width: 100%;
  position: relative;
  display: grid;
  grid-template-areas:
    "layout1 layout1"
    "layout2 layout3";
  grid-template-rows: 180px 1fr;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  overflow: hidden; /* 防止整个页面出现滚动条 */
  box-sizing: border-box;
}

.page-title {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  color: #333;
  margin: 0;
  font-size: 24px;
  font-weight: bold;
}

/* 布局1 - 顶部区域 */
.layout-1 {
  grid-area: layout1;
  position: relative;
}

/* 布局2 - 左侧源区域 */
.layout-2 {
  grid-area: layout2;
  position: relative;
  min-width: 0; /* 允许flex子元素缩小 */
  overflow: hidden; /* 防止内容溢出 */
}

/* 布局3 - 右侧目标区域 */
.layout-3 {
  grid-area: layout3;
  position: relative;
  min-width: 0; /* 允许flex子元素缩小 */
  overflow: hidden; /* 防止内容溢出 */
}

.layout-card {
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  min-width: 0; /* 允许卡片缩小 */
  overflow: hidden; /* 防止内容溢出 */
  display: flex;
  flex-direction: column;

  /* 覆盖Ant Design卡片的默认样式 */
  .ant-card-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
  }

  &:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
  }
}

/* 文字列表样式 */
.text-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  margin: 0;

  /* 自定义滚动条样式 */
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;

    &:hover {
      background: #a8a8a8;
    }
  }
}

.text-item {
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  line-height: 1.4;

  width: 100%;
  min-width: 0; /* 允许缩小 */
  box-sizing: border-box; /* 确保padding不会增加总宽度 */
  flex-shrink: 0; /* 防止被压缩，保持固定高度 */
  height: 44px; /* 设置固定高度 */
  display: flex;
  align-items: center; /* 垂直居中 */

  .text-content {
    /* 文字过长时显示省略号 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    min-width: 0;
  }

  &:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  }

  &.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }
}

/* 目标区域样式 */
.target-area {
  flex: 1;
  padding: 16px;
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  margin: 16px;

  /* 自定义滚动条样式 */
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;

    &:hover {
      background: #a8a8a8;
    }
  }
}

.empty-hint {
  color: #999;
  text-align: center;
  margin-top: 50px;
  font-style: italic;
  flex-shrink: 0; /* 防止被压缩 */
}

.target-text {
  padding: 8px 12px;
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  animation: fadeInScale 0.3s ease;

  width: 100%;
  min-width: 0; /* 允许缩小 */
  box-sizing: border-box; /* 确保padding不会增加总宽度 */
  flex-shrink: 0; /* 防止被压缩，保持固定高度 */
  height: 40px; /* 设置固定高度 */
  display: flex;
  align-items: center; /* 垂直居中 */

  .text-content {
    /* 文字过长时显示省略号 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    min-width: 0;
  }
}

/* 清空按钮 */
.clear-btn {
  background: #ff4d4f;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;

  &:hover:not(:disabled) {
    background: #ff7875;
  }

  &:disabled {
    background: #d9d9d9;
    cursor: not-allowed;
  }
}

/* 动画中的文字 */
.animating-text {
  position: absolute;
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  z-index: 1000;
  pointer-events: none;

  /* 文字过长时显示省略号 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(300px, 40vw); /* 响应式最大宽度 */
  box-sizing: border-box;

  /* 动画：从布局2移动到布局3 */
  animation: moveToTarget 1s linear forwards;
}

/* 移动动画关键帧 */
@keyframes moveToTarget {
  0% {
    /* 起始位置：布局2的中心 */
    top: 50%;
    left: 25%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  50% {
    /* 中间位置：稍微上升 */
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1; /* 保持完全不透明 */
  }

  95% {
    /* 接近结束位置：仍然保持不透明 */
    top: 50%;
    left: 75%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1; /* 保持完全不透明 */
  }

  100% {
    /* 结束位置：快速消失 */
    top: 50%;
    left: 75%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 0; /* 只在最后瞬间消失 */
  }
}

/* 目标文字淡入缩放动画 */
@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .animation-container {
    grid-template-areas:
      "layout1"
      "layout2"
      "layout3";
    grid-template-rows: 150px 1fr 1fr;
    grid-template-columns: 1fr;
    height: calc(100vh - 200px); /* 减去头部、面包屑等高度 */
    min-height: 500px; /* 设置最小高度防止过小 */
    width: 100%;
    padding: 10px;
    gap: 10px;
  }

  .page-title {
    position: relative;
    transform: none;
    left: auto;
    top: auto;
    margin-bottom: 20px;
    text-align: center;
  }

  .animating-text {
    max-width: 250px;
  }

  @keyframes moveToTarget {
    0% {
      top: 40%;
      left: 50%;
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }

    50% {
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(1.1);
      opacity: 1; /* 保持完全不透明 */
    }

    95% {
      top: 70%;
      left: 50%;
      transform: translate(-50%, -50%) scale(1);
      opacity: 1; /* 保持完全不透明 */
    }

    100% {
      top: 70%;
      left: 50%;
      transform: translate(-50%, -50%) scale(1);
      opacity: 0; /* 只在最后瞬间消失 */
    }
  }
}
